<html>
<title>Clone Case</title>

<style>
	
	BODY, TD
	{
		font-family: arial;
		font-size: 12px;
	}
	
	TD.body
	{
		border-bottom:  solid 1px #cccccc;
		text-align: center;
	}
		
</style>

<script language="javascript">

//Copyright 2006 Microsoft Corporation
//All Rights Reserved
//Provided As-Is with no support
		
	// Set global variable for the cloned case window
	var oClonedCase;
	debugger;
	function window.onload()
	{	
		// Open a new case form
		oClonedCase = window.open('/cs/cases/edit.aspx','','menubar=0, status=1, width=1000, height=600');
		
		// Set a timeout to wait for the new contact form to load
		setTimeout('checkPageState()',100);			
	}
	
	// Checks if the new case form has completed loading
	// When it completes, CloneCase will be called
	// If it's not loaded, it will set a timeout and check again.
	function checkPageState() 
	{
		if (oClonedCase.document.readyState == 'complete') 
		{
			CloneCase();
			return;
		}
		
		setTimeout('checkPageState()',100);		
	}
	
	function CloneCase()
	{
		// Get a pointer to the parent window
		var oParent = window.dialogArguments;
		
		var oSource = oParent.document.crmForm;
		
		//Set the Master Case to True to allow for ease of searching
		oSource.new_mastercase.DataValue = true; 
		
		// With the target crmForm
		with(oClonedCase.document.crmForm)
		{
			// Overview fields
			title.DataValue = (oSource.title.DataValue + " **CLONED**"); 
			subjectid.DataValue = oSource.subjectid.DataValue; 
			description.DataValue = oSource.description.DataValue; 
			customerid.DataValue = oSource.customerid.DataValue; 
			caseorigincode.DataValue = oSource.caseorigincode.DataValue; 
			casetypecode.DataValue = oSource.casetypecode.DataValue; 
			new_ordernumber.DataValue = oSource.new_ordernumber.DataValue; 
			//customersatisfactioncode.DataValue = oSource.customersatisfactioncode.DataValue; 
			//Here we are skipping the ticketnumber field as it will be auto populated
			//ticketnumber.DataValue = oSource.ticketnumber.DataValue; 
			
			
			// Assignment Information
			//ownerid.DataValue = oSource.ownerid.DataValue; 
			//followupby.DataValue = oSource.followupby.DataValue; 
			statuscode.DataValue = oSource.statuscode.DataValue; 
			prioritycode.DataValue = oSource.prioritycode.DataValue;  
			
			// Contract and Product Information
			//contractid.DataValue = oSource.contractid.DataValue;
			//contractdetailid.DataValue = oSource.contractdetailid.DataValue;
			//contractservicelevelcode.DataValue = oSource.contractservicelevelcode.DataValue;
			//productid.DataValue = oSource.productid.DataValue;
//			//productserialnumber.DataValue = oSource.productserialnumber.DataValue;
			
			// Master Case
//			new_mastercase.DataValue = true;
			new_masterticketnumber.DataValue = oSource.ticketnumber.DataValue;

		}
			
		// Finally, close the dialog	
		window.close();
	}	
	
</script>
<body  >

<table >
	<tr valign="middle">
		<td class="body" align="center">
			<div style="font-size="10pt; font-family= Tahoma;">Cloning Case...</div>
		</td>
	</tr>
</table>
</body>
</html>